char c[100],d[102];
main(i,n,p,b)
{
	for(gets(&n);b=~scanf("%d%s%s",&n,c,d+1);printf("%d\n",i))
	{
		while(b)
		{
			for(i=0;i<n;i++)
			{
				p=d[i]=='*'+d[i+1]=='*'+d[i+2]=='*';
				printf("%d %d %d\n",c[i]-48,i,p);
				if(p==c[i])
				{
					d[i]=d[i]=='*'?'*':'0';
					d[i+1]=d[i+1]=='*'?'*':'0';
					d[i+2]=d[i+2]=='*'?'*':'0';
				}
				p=d[i]!='#'+d[i+1]!='#'+d[i+2]!='#';
				if(p==c[i])
				{
					d[i]='0';
					d[i+1]='0';
					d[i+2]='0';
				}
				
			}
			printf("%s\n",d+1);
			sleep(1);

			for(b=i=0;i<n;b|=d[++i]=='#');
		}
	}
}
